<script lang='ts' setup>
import { ref, reactive } from 'vue'
import { useRoute } from 'vue-router'
import OrgJobSchedulerForm from './component/org-job-scheduler-form.vue'
import { jumpPath, redirectPath } from '/@/utils/router-kit'
import { OrgJobSchedulerListUrl, OrgJobSchedulerEditUrl } from '/@/views/org/mapping.json'
const currentRoute = useRoute()
const OrgJobSchedulerFormRef = ref()
const url = OrgJobSchedulerListUrl;
const OrgJobSchedulerFormState = reactive({
    uuid: currentRoute.params.id as string,

    /**
     * 保存按钮点击事件
     */
    onSaveButtonClick: () => {
        return OrgJobSchedulerFormRef.value.save()
    },

    /**
     * 返回按钮点击事件
     */
    onBackButtonClick: () => jumpPath(OrgJobSchedulerListUrl),

    /**
     * 新增成功回调函数
     */
    onAddFormSuccess: (formData: any) => {
        redirectPath(OrgJobSchedulerEditUrl + formData.uuid)
    },
})

</script>
<template>
    <jxtech-basic-header :breadcrumb-mapping-url="url">
        <template #extra>
            <jxtech-save-button @click="OrgJobSchedulerFormState.onSaveButtonClick"></jxtech-save-button>
            <jxtech-back-button @click="OrgJobSchedulerFormState.onBackButtonClick"></jxtech-back-button>
        </template>
    </jxtech-basic-header>
    <el-card >
        <template #header>
            <div class="jxtech-card-title">
                <span>定时任务管理</span>
            </div>
        </template>
        <org-job-scheduler-form
            ref="OrgJobSchedulerFormRef"
            :uuid="OrgJobSchedulerFormState.uuid"
            @add-success="OrgJobSchedulerFormState.onAddFormSuccess"
        ></org-job-scheduler-form>
    </el-card>
</template>